#ifndef AER_TEXTUREPROXY_HPP_
#define AER_TEXTUREPROXY_HPP_

#include <memory/aerResourceProxy.hpp>
#include <device/aerTexture.hpp>
#include "Image.hpp"


class TextureProxy : public aer::ResourceProxy<aer::Texture> 
{
  private:
    Image_t img;
    
  public:
    aer::Texture* load(const std::string& id) 
    {
      //td::cout << "TextureProxy::load > " << id << std::endl;
      img.load( id.c_str() );    
      
      aer::Texture *pTexture = new aer::Texture();
      pTexture->generate();
      
      pTexture->bind();
      pTexture->setImage( aer::Texture::TEXTURE_2D,
                          img.internalFormat, img.width, img.height, img.format, img.type,
                          img.data );                     
      aer::Texture::Unbind( aer::Texture::TEXTURE_2D );      
      img.clean();
      
      return pTexture;
    }
};

#endif // AER_TEXTUREPROXY_HPP_
